//赠送优惠卷
var handSelCoupon = {
	noCouponTiphtml : '<div class="mod_empty_page"><div class="mod_empty_page_icon"><img src="themes/img/tip/59e46980N2658925e.png"></div> <p class="mod_empty_page_main">您当前无优惠券</p></div>',
	currentLayerIndex:-1
};

handSelCoupon.init = function(result){	
	var data = result.obj || [];	
	
	if(data.length > 0){
	    template.helper('dateFormat', function (inp) {
	        if(inp!=="" && inp!==null){
	            return inp.split(' ')[0];
	        }
	        else{
	        	return "永不"
	        }
	    });    
		
		var outHtml = template("couponTempl",data);
		$("#coupon").html(outHtml);	
	
		var index = layer.open({
	        type: 1,
	        title: '优惠券',	
	        area: ["90%", "auto"],//宽高
	        content: $("#coupon").html(),
			scrollbar: false,
	        btn:['确定'],
	        yes:function (index,layero) {            
	            layer.close(index); //如果设定了yes回调，需进行手工关闭
	            
	        	var args = getQueryStringArgs();
				var callbackUrl = args["callbackUrl"];
				if(callbackUrl!==""){
					window.location.href="order.html";
				}
	            
	        },
	        cancel:function (index, layero) {
	            //右上角关闭按钮触发的回调
	            layer.close(index);
	        }
	    });
	    handSelCoupon.currentLayerIndex = index;
	}
}

//$(function(){
//	handSelCoupon.init();
//});
